//2009/08/17 18:49:10
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class SubstitutionCode
{
public:
    int getValue(string key, string code)
    {
		int ret = 0;
		for(int i=0; i<code.size(); i++)
		{
			int pos;
			if((pos = key.find(code[i])) != -1)
			{
				if(pos == key.size() -1) pos = -1;
				ret = ret * 10 + pos + 1;
			}
		}
		return ret;
    }
};
